Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "map squared" pipe operators #586

Merged
merged 2 commits into from
Jan 28, 2024
Merged

Add "map squared" pipe operators #586

merged 2 commits into from
Jan 28, 2024

Conversation

gusty
Copy link
Member

@gusty gusty commented Jan 25, 2024

This is related to #215

After many years using F#+ with Functors, Applicatives and Monads found out that:

  • Monadic code tends to read better in CEs
  • Applicative code used to read good with applicative operators but since the addition of CEs for applicatives this is becoming the default to go
  • Functors on the other side reads good with pipes, either by using |> map (or qualified map for better type inference) or by using |>>.

When it comes to composed effects we have Monad transformers which are not that great IMHO but it's the best we have so far to compose them, so we can keep writing then as CEs.

For applicatives the situation is much better as although they can be easily composed with Compose we can take advantage of applicative2 and applicative3 CEs.

Now the missing piece seems to be Functors, right now for piping composed Functors I normally use something like
|>> map .. (or qualified) which doesn't read bad, type inference is quite good usually but I feel like we should support |>>> to allow that option, plus eventually we can use |>>> map for 3-layered Functors, at least until we decide to add |>>>>.

For more information, I find a lot of composed functors in the wild, namely stuff like Task<Result< >> which I see many developers using custom CEs for it, but most of the time it doesn't need it as it's code that can be piped.

@gusty gusty marked this pull request as ready for review January 28, 2024 09:44
@gusty gusty merged commit ac120e9 into master Jan 28, 2024
6 checks passed
@gusty gusty mentioned this pull request Jan 28, 2024
@gusty gusty deleted the gus/deep-map-ops branch February 12, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant